#ifndef __CACHE_H__
#define __CACHE_H__

#include "common.h"

#define CACHE_BLOCK_BIT 6
#define CACHE_WAY_BIT_F 8
#define CACHE_GROUP_BIT 7
#define CACHE_WAY_BIT_S 16

#define CACHE_BLOCK_SIZE (1<<CACHE_BLOCK_BIT)
#define CACHE_SIZE_F (64*1024)
#define CACHE_SIZE_S (4*1024*1024)

typedef struct {
	bool Valid;
	uint32_t tag;
	uint8_t data[CACHE_BLOCK_SIZE];
}first_cache;

first_cache caf[CACHE_SIZE_F/CACHE_BLOCK_SIZE];

typedef struct {
	bool Valid;
	bool dirty;
	uint32_t tag;
        uint8_t data[CACHE_BLOCK_SIZE];
}second_cache;

second_cache cas[CACHE_SIZE_S/CACHE_BLOCK_SIZE];

int Time;

void init_cache();
uint32_t cache_read_f(hwaddr_t addr);
uint32_t cache_read_s(hwaddr_t addr);
void cache_write_f(hwaddr_t addr,size_t len,uint32_t data);
void cache_write_s(hwaddr_t addr,size_t len,uint32_t data);

#endif
